﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Hired
{
    public partial class message : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["recipient"] != null)
            {
                txtRecipient.Text = (string)(Session["recipient"]);
            }
        }

        protected void btnSend_Click(object sender, EventArgs e)
        {
            // check current user's id
            string recipient = txtRecipient.Text;
            string subject = txtSubject.Text;
            string content = txtContent.Text;

            Message m = new Message();
            // m.SenderID = DBAccount.RetrieveAccountIDByUsername(sessionvariable);
            m.RecipientID = DBAccount.RetrieveAccountIDByUsername(recipient);
            m.Title = subject;
            m.Contents = content;
            m.Timestamp = DateTime.Now;
            DBMessage.AddMessage(m);
        }
    }
}